﻿using System;

namespace SUT
{
    public class NetworkMonitor
    {
        readonly INode m_node;

        public NetworkMonitor(INode node)
        {
            m_node = node;
        }

        public void Check(params String[] addresses)
        {
            FailingNodes = 0;
            foreach (var address in addresses)
            {
                try
                {
                    if (m_node.GetIPStatus(address) == false)
                        FailingNodes++;
                }
                catch (Exception)
                {
                    FailingNodes++;
                }

            }
            IsUpAndRunning = FailingNodes == 0;
        }

        public int FailingNodes { get; private set; }

        public bool IsUpAndRunning { get; private set; }
    }
}
